import axios from '@/utils/request'
// import store from '@/store'

/**
 *用户登录
 * @param {*} mobile 手机号
 * @param {*} code 密码
 * @returns
 */
export const userLogin = (mobile, code) => {
  return axios({
    method: 'post',
    url: '/v1_0/authorizations',
    data: {
      mobile,
      code
    }
  })
}

export const getUser = () => {
  // const token = store.state.user.token.token
  return axios({
    method: 'GET',
    url: '/v1_0/user'
    // headers: {
    //   Authorization: 'Bearer ' + token
    // }
  })
}

export const getUserInfo = () => {
  // const token = store.state.user.token.token
  return axios({
    method: 'GET',
    url: '/v1_0/user/profile'
    // headers: {
    //   Authorization: 'Bearer ' + token
    // }
  })
}

/**
 * 编辑用户个人资料
 *
 * @export
 * @param {*} data 是个对象，里面需要有修改的数据 name ，gender
 * @return {*}
 */
export function editUserProfile(data) {
  return axios({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })
}
